﻿using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using LibKetoan;
using doiso;

namespace Ketoan
{
	/// <summary>
	/// Summary description for frmCongno.
	/// </summary>
	public class frmCongno_cu : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label label9;
		private System.Windows.Forms.DataGrid dataGrid1;
		private System.Windows.Forms.Button butMoi;
		private System.Windows.Forms.Button butSua;
		private System.Windows.Forms.Button butLuu;
		private System.Windows.Forms.Button butBoqua;
		private System.Windows.Forms.Button butHuy;
		private System.Windows.Forms.Button butIn;
		private System.Windows.Forms.Button butKetthuc;
		private string s_mmyy,sql,format_sotien,table="a_congno";
		private int i_userid,itable;
		private long l_id,l_idold;
		private bool bKhoaso,bNew,bAdmin;
		private AccessData a;
		private Doisototext doiso=new Doisototext();
		private DataTable dtmtm=new DataTable();
		private DataTable dtct=new DataTable();
		private DataTable dttk=new DataTable();
		private DataTable dtnt=new DataTable();
		private DataTable dtdt=new DataTable();
		private DataRow r;
		private System.Windows.Forms.TextBox stt;
		private System.Windows.Forms.TextBox find;
		private System.Windows.Forms.CheckBox chkIn;
		private System.Windows.Forms.ToolTip toolTip1;
		private System.ComponentModel.IContainer components;
		private System.Windows.Forms.Label label37;
		private System.Windows.Forms.Label label43;
		private System.Windows.Forms.ComboBox hoatdong;
		private System.Windows.Forms.Label label6;
		private System.Windows.Forms.ComboBox chuong;
		private System.Windows.Forms.Label label7;
		private System.Windows.Forms.ComboBox nghiepvu;
		private System.Windows.Forms.Label label50;
		private System.Windows.Forms.ComboBox lk;
		private System.Windows.Forms.TextBox ttkno;
		private System.Windows.Forms.TextBox tkno;
		private System.Windows.Forms.Label label13;
		private MaskedTextBox.MaskedTextBox tygia;
		private System.Windows.Forms.ComboBox ngoaite;
		private System.Windows.Forms.Label label25;
		private string s_chuong,s_lk,s_nghiepvu;
		private System.Windows.Forms.TextBox stemp;
		private LibList.List listtkno;
		private long ltkno,lmadt;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.TextBox zsdno;
		private System.Windows.Forms.TextBox zsdco;
		private MaskedTextBox.MaskedTextBox zsdcont;
		private MaskedTextBox.MaskedTextBox zsdnont;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.Label label5;
		private System.Windows.Forms.Label label8;
		private System.Windows.Forms.Label label10;
		private LibList.List listdt;
		private System.Windows.Forms.TextBox tendt;
		private System.Windows.Forms.TextBox madt;
		private System.Windows.Forms.Label label27;
		private MaskedTextBox.MaskedTextBox diachi;
		private System.Windows.Forms.Label label46;
		private System.Windows.Forms.ComboBox kmno;
		private System.Windows.Forms.Label label17;
		private System.Windows.Forms.ComboBox nhom;
		private System.Windows.Forms.Label label11;
		private System.Windows.Forms.Label label12;
		private System.Windows.Forms.ComboBox kmno2;
		private System.Windows.Forms.ComboBox kmno3;
		private System.Windows.Forms.Label label14;
		private System.Windows.Forms.Label label15;
		private System.Windows.Forms.ComboBox kmno4;
		private System.Windows.Forms.TextBox sdno;
		private System.Windows.Forms.TextBox sdco;
		private System.Windows.Forms.TextBox sdcont;
		private System.Windows.Forms.TextBox sdnont;
		private System.Windows.Forms.Label label3;

		public frmCongno_cu(AccessData acc,string mmyy,string _chuong,string _lk,string _nghiepvu,int userid,string title,bool admin)
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
			a=acc;i_userid=userid;s_mmyy=mmyy;
			s_chuong=_chuong;s_lk=_lk;s_nghiepvu=_nghiepvu;
			bAdmin=admin;this.Text=title;
			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmCongno_cu));
			this.label9 = new System.Windows.Forms.Label();
			this.hoatdong = new System.Windows.Forms.ComboBox();
			this.dataGrid1 = new System.Windows.Forms.DataGrid();
			this.butMoi = new System.Windows.Forms.Button();
			this.butSua = new System.Windows.Forms.Button();
			this.butLuu = new System.Windows.Forms.Button();
			this.butBoqua = new System.Windows.Forms.Button();
			this.butHuy = new System.Windows.Forms.Button();
			this.butIn = new System.Windows.Forms.Button();
			this.butKetthuc = new System.Windows.Forms.Button();
			this.zsdno = new System.Windows.Forms.TextBox();
			this.zsdco = new System.Windows.Forms.TextBox();
			this.stt = new System.Windows.Forms.TextBox();
			this.find = new System.Windows.Forms.TextBox();
			this.chkIn = new System.Windows.Forms.CheckBox();
			this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
			this.tygia = new MaskedTextBox.MaskedTextBox();
			this.label37 = new System.Windows.Forms.Label();
			this.label43 = new System.Windows.Forms.Label();
			this.label6 = new System.Windows.Forms.Label();
			this.chuong = new System.Windows.Forms.ComboBox();
			this.label7 = new System.Windows.Forms.Label();
			this.nghiepvu = new System.Windows.Forms.ComboBox();
			this.label50 = new System.Windows.Forms.Label();
			this.lk = new System.Windows.Forms.ComboBox();
			this.ttkno = new System.Windows.Forms.TextBox();
			this.tkno = new System.Windows.Forms.TextBox();
			this.label13 = new System.Windows.Forms.Label();
			this.ngoaite = new System.Windows.Forms.ComboBox();
			this.label25 = new System.Windows.Forms.Label();
			this.stemp = new System.Windows.Forms.TextBox();
			this.listtkno = new LibList.List();
			this.label1 = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			this.label3 = new System.Windows.Forms.Label();
			this.zsdcont = new MaskedTextBox.MaskedTextBox();
			this.zsdnont = new MaskedTextBox.MaskedTextBox();
			this.label4 = new System.Windows.Forms.Label();
			this.label5 = new System.Windows.Forms.Label();
			this.label8 = new System.Windows.Forms.Label();
			this.label10 = new System.Windows.Forms.Label();
			this.listdt = new LibList.List();
			this.tendt = new System.Windows.Forms.TextBox();
			this.madt = new System.Windows.Forms.TextBox();
			this.label27 = new System.Windows.Forms.Label();
			this.diachi = new MaskedTextBox.MaskedTextBox();
			this.label46 = new System.Windows.Forms.Label();
			this.kmno = new System.Windows.Forms.ComboBox();
			this.label17 = new System.Windows.Forms.Label();
			this.nhom = new System.Windows.Forms.ComboBox();
			this.label11 = new System.Windows.Forms.Label();
			this.kmno2 = new System.Windows.Forms.ComboBox();
			this.label12 = new System.Windows.Forms.Label();
			this.kmno3 = new System.Windows.Forms.ComboBox();
			this.label14 = new System.Windows.Forms.Label();
			this.label15 = new System.Windows.Forms.Label();
			this.kmno4 = new System.Windows.Forms.ComboBox();
			this.sdno = new System.Windows.Forms.TextBox();
			this.sdco = new System.Windows.Forms.TextBox();
			this.sdcont = new System.Windows.Forms.TextBox();
			this.sdnont = new System.Windows.Forms.TextBox();
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
			this.SuspendLayout();
			// 
			// label9
			// 
			this.label9.Location = new System.Drawing.Point(296, 4);
			this.label9.Name = "label9";
			this.label9.Size = new System.Drawing.Size(64, 23);
			this.label9.TabIndex = 0;
			this.label9.Text = "Hoạt động :";
			this.label9.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// hoatdong
			// 
			this.hoatdong.BackColor = System.Drawing.SystemColors.HighlightText;
			this.hoatdong.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.hoatdong.Enabled = false;
			this.hoatdong.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.hoatdong.Location = new System.Drawing.Point(360, 4);
			this.hoatdong.Name = "hoatdong";
			this.hoatdong.Size = new System.Drawing.Size(157, 21);
			this.hoatdong.TabIndex = 2;
			this.hoatdong.KeyDown += new System.Windows.Forms.KeyEventHandler(this.hoatdong_KeyDown);
			// 
			// dataGrid1
			// 
			this.dataGrid1.AlternatingBackColor = System.Drawing.Color.Lavender;
			this.dataGrid1.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
				| System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			this.dataGrid1.BackColor = System.Drawing.Color.WhiteSmoke;
			this.dataGrid1.BackgroundColor = System.Drawing.SystemColors.Control;
			this.dataGrid1.BorderStyle = System.Windows.Forms.BorderStyle.None;
			this.dataGrid1.CaptionBackColor = System.Drawing.SystemColors.Control;
			this.dataGrid1.CaptionFont = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.dataGrid1.CaptionForeColor = System.Drawing.Color.MidnightBlue;
			this.dataGrid1.DataMember = "";
			this.dataGrid1.FlatMode = true;
			this.dataGrid1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.dataGrid1.ForeColor = System.Drawing.Color.MidnightBlue;
			this.dataGrid1.GridLineColor = System.Drawing.Color.Gainsboro;
			this.dataGrid1.GridLineStyle = System.Windows.Forms.DataGridLineStyle.None;
			this.dataGrid1.HeaderFont = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Bold);
			this.dataGrid1.HeaderForeColor = System.Drawing.Color.WhiteSmoke;
			this.dataGrid1.LinkColor = System.Drawing.Color.Teal;
			this.dataGrid1.Location = new System.Drawing.Point(8, 16);
			this.dataGrid1.Name = "dataGrid1";
			this.dataGrid1.ParentRowsBackColor = System.Drawing.Color.Gainsboro;
			this.dataGrid1.ParentRowsForeColor = System.Drawing.Color.MidnightBlue;
			this.dataGrid1.ReadOnly = true;
			this.dataGrid1.RowHeaderWidth = 10;
			this.dataGrid1.SelectionBackColor = System.Drawing.Color.CadetBlue;
			this.dataGrid1.SelectionForeColor = System.Drawing.Color.WhiteSmoke;
			this.dataGrid1.Size = new System.Drawing.Size(776, 296);
			this.dataGrid1.TabIndex = 90;
			this.dataGrid1.CurrentCellChanged += new System.EventHandler(this.dataGrid1_CurrentCellChanged);
			// 
			// butMoi
			// 
			this.butMoi.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.butMoi.Image = ((System.Drawing.Bitmap)(resources.GetObject("butMoi.Image")));
			this.butMoi.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.butMoi.Location = new System.Drawing.Point(172, 491);
			this.butMoi.Name = "butMoi";
			this.butMoi.Size = new System.Drawing.Size(60, 25);
			this.butMoi.TabIndex = 84;
			this.butMoi.Text = "      &Mới";
			this.butMoi.Click += new System.EventHandler(this.butMoi_Click);
			// 
			// butSua
			// 
			this.butSua.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.butSua.Image = ((System.Drawing.Bitmap)(resources.GetObject("butSua.Image")));
			this.butSua.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.butSua.Location = new System.Drawing.Point(235, 491);
			this.butSua.Name = "butSua";
			this.butSua.Size = new System.Drawing.Size(60, 25);
			this.butSua.TabIndex = 85;
			this.butSua.Text = "     &Sửa";
			this.butSua.Click += new System.EventHandler(this.butSua_Click);
			// 
			// butLuu
			// 
			this.butLuu.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.butLuu.Enabled = false;
			this.butLuu.Image = ((System.Drawing.Bitmap)(resources.GetObject("butLuu.Image")));
			this.butLuu.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.butLuu.Location = new System.Drawing.Point(298, 491);
			this.butLuu.Name = "butLuu";
			this.butLuu.Size = new System.Drawing.Size(60, 25);
			this.butLuu.TabIndex = 82;
			this.butLuu.Text = "     &Lưu";
			this.butLuu.Click += new System.EventHandler(this.butLuu_Click);
			// 
			// butBoqua
			// 
			this.butBoqua.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.butBoqua.Enabled = false;
			this.butBoqua.Image = ((System.Drawing.Bitmap)(resources.GetObject("butBoqua.Image")));
			this.butBoqua.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.butBoqua.Location = new System.Drawing.Point(361, 491);
			this.butBoqua.Name = "butBoqua";
			this.butBoqua.Size = new System.Drawing.Size(60, 25);
			this.butBoqua.TabIndex = 83;
			this.butBoqua.Text = "&Bỏ qua";
			this.butBoqua.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			this.butBoqua.Click += new System.EventHandler(this.butBoqua_Click);
			// 
			// butHuy
			// 
			this.butHuy.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.butHuy.Image = ((System.Drawing.Bitmap)(resources.GetObject("butHuy.Image")));
			this.butHuy.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.butHuy.Location = new System.Drawing.Point(424, 491);
			this.butHuy.Name = "butHuy";
			this.butHuy.Size = new System.Drawing.Size(60, 25);
			this.butHuy.TabIndex = 86;
			this.butHuy.Text = "     &Hủy";
			this.butHuy.Click += new System.EventHandler(this.butHuy_Click);
			// 
			// butIn
			// 
			this.butIn.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.butIn.Image = ((System.Drawing.Bitmap)(resources.GetObject("butIn.Image")));
			this.butIn.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.butIn.Location = new System.Drawing.Point(487, 491);
			this.butIn.Name = "butIn";
			this.butIn.Size = new System.Drawing.Size(60, 25);
			this.butIn.TabIndex = 87;
			this.butIn.Text = "      &In";
			this.butIn.Click += new System.EventHandler(this.butIn_Click);
			// 
			// butKetthuc
			// 
			this.butKetthuc.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.butKetthuc.Image = ((System.Drawing.Bitmap)(resources.GetObject("butKetthuc.Image")));
			this.butKetthuc.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.butKetthuc.Location = new System.Drawing.Point(550, 491);
			this.butKetthuc.Name = "butKetthuc";
			this.butKetthuc.Size = new System.Drawing.Size(70, 25);
			this.butKetthuc.TabIndex = 88;
			this.butKetthuc.Text = "&Kết thúc";
			this.butKetthuc.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			this.butKetthuc.Click += new System.EventHandler(this.butKetthuc_Click);
			// 
			// zsdno
			// 
			this.zsdno.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.zsdno.BackColor = System.Drawing.SystemColors.HighlightText;
			this.zsdno.Enabled = false;
			this.zsdno.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.zsdno.Location = new System.Drawing.Point(477, 323);
			this.zsdno.Name = "zsdno";
			this.zsdno.Size = new System.Drawing.Size(125, 21);
			this.zsdno.TabIndex = 95;
			this.zsdno.Text = "";
			this.zsdno.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
			// 
			// zsdco
			// 
			this.zsdco.Anchor = ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			this.zsdco.BackColor = System.Drawing.SystemColors.HighlightText;
			this.zsdco.Enabled = false;
			this.zsdco.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.zsdco.Location = new System.Drawing.Point(656, 323);
			this.zsdco.Name = "zsdco";
			this.zsdco.Size = new System.Drawing.Size(128, 21);
			this.zsdco.TabIndex = 96;
			this.zsdco.Text = "";
			this.zsdco.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
			// 
			// stt
			// 
			this.stt.Enabled = false;
			this.stt.Location = new System.Drawing.Point(64, 225);
			this.stt.Name = "stt";
			this.stt.Size = new System.Drawing.Size(40, 20);
			this.stt.TabIndex = 91;
			this.stt.Text = "";
			// 
			// find
			// 
			this.find.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right);
			this.find.BackColor = System.Drawing.SystemColors.HighlightText;
			this.find.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.find.ForeColor = System.Drawing.Color.Red;
			this.find.Location = new System.Drawing.Point(704, 4);
			this.find.Name = "find";
			this.find.Size = new System.Drawing.Size(80, 21);
			this.find.TabIndex = 89;
			this.find.Text = "Tìm kiếm";
			this.find.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
			this.find.TextChanged += new System.EventHandler(this.find_TextChanged);
			this.find.Enter += new System.EventHandler(this.find_Enter);
			// 
			// chkIn
			// 
			this.chkIn.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.chkIn.Location = new System.Drawing.Point(656, 488);
			this.chkIn.Name = "chkIn";
			this.chkIn.Size = new System.Drawing.Size(112, 16);
			this.chkIn.TabIndex = 98;
			this.chkIn.Text = "Xem trước khi in";
			// 
			// tygia
			// 
			this.tygia.Anchor = ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			this.tygia.BackColor = System.Drawing.SystemColors.HighlightText;
			this.tygia.Enabled = false;
			this.tygia.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.tygia.Location = new System.Drawing.Point(656, 440);
			this.tygia.Masked = MaskedTextBox.MaskedTextBox.Mask.None;
			this.tygia.Name = "tygia";
			this.tygia.Size = new System.Drawing.Size(128, 21);
			this.tygia.TabIndex = 15;
			this.tygia.Text = "";
			this.tygia.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
			// 
			// label37
			// 
			this.label37.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.label37.Location = new System.Drawing.Point(600, 440);
			this.label37.Name = "label37";
			this.label37.Size = new System.Drawing.Size(56, 23);
			this.label37.TabIndex = 73;
			this.label37.Text = "Tỷ giá :";
			this.label37.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// label43
			// 
			this.label43.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.label43.Location = new System.Drawing.Point(410, 464);
			this.label43.Name = "label43";
			this.label43.Size = new System.Drawing.Size(64, 23);
			this.label43.TabIndex = 75;
			this.label43.Text = "Thu VND :";
			this.label43.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// label6
			// 
			this.label6.Location = new System.Drawing.Point(152, 4);
			this.label6.Name = "label6";
			this.label6.Size = new System.Drawing.Size(56, 23);
			this.label6.TabIndex = 13;
			this.label6.Text = "Chương :";
			this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// chuong
			// 
			this.chuong.BackColor = System.Drawing.SystemColors.HighlightText;
			this.chuong.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.chuong.Enabled = false;
			this.chuong.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.chuong.Location = new System.Drawing.Point(208, 4);
			this.chuong.Name = "chuong";
			this.chuong.Size = new System.Drawing.Size(88, 21);
			this.chuong.TabIndex = 1;
			this.chuong.KeyDown += new System.Windows.Forms.KeyEventHandler(this.hoatdong_KeyDown);
			// 
			// label7
			// 
			this.label7.Location = new System.Drawing.Point(518, 4);
			this.label7.Name = "label7";
			this.label7.Size = new System.Drawing.Size(56, 23);
			this.label7.TabIndex = 15;
			this.label7.Text = "Nhiệp vụ :";
			this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// nghiepvu
			// 
			this.nghiepvu.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			this.nghiepvu.BackColor = System.Drawing.SystemColors.HighlightText;
			this.nghiepvu.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.nghiepvu.Enabled = false;
			this.nghiepvu.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.nghiepvu.Location = new System.Drawing.Point(574, 4);
			this.nghiepvu.Name = "nghiepvu";
			this.nghiepvu.Size = new System.Drawing.Size(128, 21);
			this.nghiepvu.TabIndex = 3;
			this.nghiepvu.KeyDown += new System.Windows.Forms.KeyEventHandler(this.hoatdong_KeyDown);
			// 
			// label50
			// 
			this.label50.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.label50.Location = new System.Drawing.Point(8, 347);
			this.label50.Name = "label50";
			this.label50.Size = new System.Drawing.Size(72, 23);
			this.label50.TabIndex = 49;
			this.label50.Text = "Loại khoản :";
			this.label50.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// lk
			// 
			this.lk.Anchor = ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			this.lk.BackColor = System.Drawing.SystemColors.HighlightText;
			this.lk.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.lk.Enabled = false;
			this.lk.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.lk.Location = new System.Drawing.Point(83, 347);
			this.lk.Name = "lk";
			this.lk.Size = new System.Drawing.Size(128, 21);
			this.lk.TabIndex = 4;
			this.lk.KeyDown += new System.Windows.Forms.KeyEventHandler(this.hoatdong_KeyDown);
			// 
			// ttkno
			// 
			this.ttkno.Anchor = ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			this.ttkno.BackColor = System.Drawing.SystemColors.HighlightText;
			this.ttkno.Enabled = false;
			this.ttkno.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.ttkno.Location = new System.Drawing.Point(187, 393);
			this.ttkno.Name = "ttkno";
			this.ttkno.Size = new System.Drawing.Size(597, 21);
			this.ttkno.TabIndex = 9;
			this.ttkno.Text = "";
			// 
			// tkno
			// 
			this.tkno.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.tkno.BackColor = System.Drawing.SystemColors.HighlightText;
			this.tkno.Enabled = false;
			this.tkno.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.tkno.Location = new System.Drawing.Point(83, 393);
			this.tkno.Name = "tkno";
			this.tkno.Size = new System.Drawing.Size(101, 21);
			this.tkno.TabIndex = 8;
			this.tkno.Text = "";
			this.tkno.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tkno_KeyDown);
			this.tkno.Validated += new System.EventHandler(this.tkno_Validated);
			this.tkno.TextChanged += new System.EventHandler(this.tkno_TextChanged);
			// 
			// label13
			// 
			this.label13.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.label13.Location = new System.Drawing.Point(0, 393);
			this.label13.Name = "label13";
			this.label13.Size = new System.Drawing.Size(80, 23);
			this.label13.TabIndex = 51;
			this.label13.Text = "Số tài khoản :";
			this.label13.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// ngoaite
			// 
			this.ngoaite.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.ngoaite.BackColor = System.Drawing.SystemColors.HighlightText;
			this.ngoaite.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.ngoaite.Enabled = false;
			this.ngoaite.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.ngoaite.Location = new System.Drawing.Point(474, 440);
			this.ngoaite.Name = "ngoaite";
			this.ngoaite.Size = new System.Drawing.Size(110, 21);
			this.ngoaite.TabIndex = 14;
			this.ngoaite.KeyDown += new System.Windows.Forms.KeyEventHandler(this.hoatdong_KeyDown);
			this.ngoaite.SelectedIndexChanged += new System.EventHandler(this.ngoaite_SelectedIndexChanged);
			// 
			// label25
			// 
			this.label25.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.label25.Location = new System.Drawing.Point(396, 440);
			this.label25.Name = "label25";
			this.label25.Size = new System.Drawing.Size(80, 23);
			this.label25.TabIndex = 71;
			this.label25.Text = "Ngoại tệ :";
			this.label25.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// stemp
			// 
			this.stemp.Enabled = false;
			this.stemp.Location = new System.Drawing.Point(576, 224);
			this.stemp.Name = "stemp";
			this.stemp.TabIndex = 103;
			this.stemp.Text = "";
			// 
			// listtkno
			// 
			this.listtkno.BackColor = System.Drawing.SystemColors.Info;
			this.listtkno.ColumnCount = 0;
			this.listtkno.Location = new System.Drawing.Point(232, 544);
			this.listtkno.MatchBufferTimeOut = 1000;
			this.listtkno.MatchEntryStyle = AsYetUnnamed.MatchEntryStyle.FirstLetterInsensitive;
			this.listtkno.Name = "listtkno";
			this.listtkno.Size = new System.Drawing.Size(75, 17);
			this.listtkno.TabIndex = 104;
			this.listtkno.TextIndex = -1;
			this.listtkno.TextMember = null;
			this.listtkno.ValueIndex = -1;
			this.listtkno.Visible = false;
			this.listtkno.KeyDown += new System.Windows.Forms.KeyEventHandler(this.listtkno_KeyDown);
			// 
			// label1
			// 
			this.label1.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.label1.Location = new System.Drawing.Point(600, 464);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(56, 23);
			this.label1.TabIndex = 108;
			this.label1.Text = "Trả VND :";
			this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// label2
			// 
			this.label2.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.label2.Location = new System.Drawing.Point(216, 464);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(72, 23);
			this.label2.TabIndex = 110;
			this.label2.Text = "Trả ngoại tệ :";
			this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// label3
			// 
			this.label3.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.label3.Location = new System.Drawing.Point(0, 464);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(80, 23);
			this.label3.TabIndex = 109;
			this.label3.Text = "Thu ngoại tệ :";
			this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// zsdcont
			// 
			this.zsdcont.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.zsdcont.BackColor = System.Drawing.SystemColors.HighlightText;
			this.zsdcont.Enabled = false;
			this.zsdcont.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.zsdcont.Location = new System.Drawing.Point(288, 323);
			this.zsdcont.Masked = MaskedTextBox.MaskedTextBox.Mask.None;
			this.zsdcont.Name = "zsdcont";
			this.zsdcont.Size = new System.Drawing.Size(128, 21);
			this.zsdcont.TabIndex = 112;
			this.zsdcont.Text = "";
			this.zsdcont.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
			// 
			// zsdnont
			// 
			this.zsdnont.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.zsdnont.BackColor = System.Drawing.SystemColors.HighlightText;
			this.zsdnont.Enabled = false;
			this.zsdnont.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.zsdnont.Location = new System.Drawing.Point(83, 323);
			this.zsdnont.Masked = MaskedTextBox.MaskedTextBox.Mask.None;
			this.zsdnont.Name = "zsdnont";
			this.zsdnont.Size = new System.Drawing.Size(128, 21);
			this.zsdnont.TabIndex = 111;
			this.zsdnont.Text = "";
			this.zsdnont.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
			// 
			// label4
			// 
			this.label4.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.label4.Location = new System.Drawing.Point(216, 323);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(72, 23);
			this.label4.TabIndex = 116;
			this.label4.Text = "Trả ngoại tệ :";
			this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// label5
			// 
			this.label5.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.label5.Location = new System.Drawing.Point(0, 323);
			this.label5.Name = "label5";
			this.label5.Size = new System.Drawing.Size(80, 23);
			this.label5.TabIndex = 115;
			this.label5.Text = "Thu ngoại tệ :";
			this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// label8
			// 
			this.label8.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.label8.Location = new System.Drawing.Point(600, 323);
			this.label8.Name = "label8";
			this.label8.Size = new System.Drawing.Size(56, 23);
			this.label8.TabIndex = 114;
			this.label8.Text = "Trả VND :";
			this.label8.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// label10
			// 
			this.label10.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.label10.Location = new System.Drawing.Point(410, 323);
			this.label10.Name = "label10";
			this.label10.Size = new System.Drawing.Size(64, 22);
			this.label10.TabIndex = 113;
			this.label10.Text = "Thu VND :";
			this.label10.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// listdt
			// 
			this.listdt.BackColor = System.Drawing.SystemColors.Info;
			this.listdt.ColumnCount = 0;
			this.listdt.Location = new System.Drawing.Point(464, 536);
			this.listdt.MatchBufferTimeOut = 1000;
			this.listdt.MatchEntryStyle = AsYetUnnamed.MatchEntryStyle.FirstLetterInsensitive;
			this.listdt.Name = "listdt";
			this.listdt.Size = new System.Drawing.Size(75, 17);
			this.listdt.TabIndex = 117;
			this.listdt.TextIndex = -1;
			this.listdt.TextMember = null;
			this.listdt.ValueIndex = -1;
			this.listdt.Visible = false;
			this.listdt.KeyDown += new System.Windows.Forms.KeyEventHandler(this.listdt_KeyDown);
			this.listdt.DoubleClick += new System.EventHandler(this.listdt_DoubleClick);
			// 
			// tendt
			// 
			this.tendt.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.tendt.BackColor = System.Drawing.SystemColors.HighlightText;
			this.tendt.Enabled = false;
			this.tendt.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.tendt.Location = new System.Drawing.Point(360, 347);
			this.tendt.Name = "tendt";
			this.tendt.Size = new System.Drawing.Size(424, 21);
			this.tendt.TabIndex = 6;
			this.tendt.Text = "";
			this.tendt.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tendt_KeyDown);
			this.tendt.TextChanged += new System.EventHandler(this.tendt_TextChanged);
			this.tendt.DoubleClick += new System.EventHandler(this.tendt_DoubleClick);
			// 
			// madt
			// 
			this.madt.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.madt.BackColor = System.Drawing.SystemColors.HighlightText;
			this.madt.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
			this.madt.Enabled = false;
			this.madt.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.madt.Location = new System.Drawing.Point(288, 347);
			this.madt.Name = "madt";
			this.madt.Size = new System.Drawing.Size(70, 21);
			this.madt.TabIndex = 5;
			this.madt.Text = "";
			this.madt.KeyDown += new System.Windows.Forms.KeyEventHandler(this.hoatdong_KeyDown);
			this.madt.Validated += new System.EventHandler(this.madt_Validated);
			// 
			// label27
			// 
			this.label27.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.label27.Location = new System.Drawing.Point(208, 347);
			this.label27.Name = "label27";
			this.label27.Size = new System.Drawing.Size(80, 23);
			this.label27.TabIndex = 120;
			this.label27.Text = "Đối tượng :";
			this.label27.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// diachi
			// 
			this.diachi.Anchor = ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			this.diachi.BackColor = System.Drawing.SystemColors.HighlightText;
			this.diachi.Enabled = false;
			this.diachi.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.diachi.Location = new System.Drawing.Point(83, 370);
			this.diachi.Masked = MaskedTextBox.MaskedTextBox.Mask.None;
			this.diachi.Name = "diachi";
			this.diachi.Size = new System.Drawing.Size(701, 21);
			this.diachi.TabIndex = 7;
			this.diachi.Text = "";
			// 
			// label46
			// 
			this.label46.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.label46.Location = new System.Drawing.Point(16, 370);
			this.label46.Name = "label46";
			this.label46.Size = new System.Drawing.Size(64, 23);
			this.label46.TabIndex = 123;
			this.label46.Text = "Địa chỉ :";
			this.label46.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// kmno
			// 
			this.kmno.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.kmno.BackColor = System.Drawing.SystemColors.HighlightText;
			this.kmno.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.kmno.Enabled = false;
			this.kmno.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.kmno.Location = new System.Drawing.Point(83, 416);
			this.kmno.Name = "kmno";
			this.kmno.Size = new System.Drawing.Size(205, 21);
			this.kmno.TabIndex = 10;
			this.kmno.KeyDown += new System.Windows.Forms.KeyEventHandler(this.hoatdong_KeyDown);
			// 
			// label17
			// 
			this.label17.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.label17.Location = new System.Drawing.Point(0, 416);
			this.label17.Name = "label17";
			this.label17.Size = new System.Drawing.Size(80, 23);
			this.label17.TabIndex = 125;
			this.label17.Text = "Khoản mục 1 :";
			this.label17.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// nhom
			// 
			this.nhom.BackColor = System.Drawing.SystemColors.HighlightText;
			this.nhom.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.nhom.Enabled = false;
			this.nhom.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.nhom.Location = new System.Drawing.Point(40, 4);
			this.nhom.Name = "nhom";
			this.nhom.Size = new System.Drawing.Size(120, 21);
			this.nhom.TabIndex = 0;
			this.nhom.KeyDown += new System.Windows.Forms.KeyEventHandler(this.hoatdong_KeyDown);
			// 
			// label11
			// 
			this.label11.Location = new System.Drawing.Point(-16, 4);
			this.label11.Name = "label11";
			this.label11.Size = new System.Drawing.Size(56, 23);
			this.label11.TabIndex = 127;
			this.label11.Text = "Nhóm :";
			this.label11.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// kmno2
			// 
			this.kmno2.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.kmno2.BackColor = System.Drawing.SystemColors.HighlightText;
			this.kmno2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.kmno2.Enabled = false;
			this.kmno2.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.kmno2.Location = new System.Drawing.Point(360, 416);
			this.kmno2.Name = "kmno2";
			this.kmno2.Size = new System.Drawing.Size(224, 21);
			this.kmno2.TabIndex = 11;
			this.kmno2.KeyDown += new System.Windows.Forms.KeyEventHandler(this.hoatdong_KeyDown);
			// 
			// label12
			// 
			this.label12.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.label12.Location = new System.Drawing.Point(280, 416);
			this.label12.Name = "label12";
			this.label12.Size = new System.Drawing.Size(80, 23);
			this.label12.TabIndex = 129;
			this.label12.Text = "Khoản mục 2 :";
			this.label12.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// kmno3
			// 
			this.kmno3.Anchor = ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			this.kmno3.BackColor = System.Drawing.SystemColors.HighlightText;
			this.kmno3.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.kmno3.Enabled = false;
			this.kmno3.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.kmno3.Location = new System.Drawing.Point(656, 416);
			this.kmno3.Name = "kmno3";
			this.kmno3.Size = new System.Drawing.Size(128, 21);
			this.kmno3.TabIndex = 12;
			this.kmno3.KeyDown += new System.Windows.Forms.KeyEventHandler(this.hoatdong_KeyDown);
			// 
			// label14
			// 
			this.label14.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.label14.Location = new System.Drawing.Point(560, 416);
			this.label14.Name = "label14";
			this.label14.Size = new System.Drawing.Size(96, 23);
			this.label14.TabIndex = 131;
			this.label14.Text = "Khoản mục 3 :";
			this.label14.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// label15
			// 
			this.label15.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.label15.Location = new System.Drawing.Point(0, 440);
			this.label15.Name = "label15";
			this.label15.Size = new System.Drawing.Size(80, 23);
			this.label15.TabIndex = 132;
			this.label15.Text = "Khoản mục 4 :";
			this.label15.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// kmno4
			// 
			this.kmno4.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.kmno4.BackColor = System.Drawing.SystemColors.HighlightText;
			this.kmno4.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.kmno4.Enabled = false;
			this.kmno4.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.kmno4.Location = new System.Drawing.Point(83, 440);
			this.kmno4.Name = "kmno4";
			this.kmno4.Size = new System.Drawing.Size(335, 21);
			this.kmno4.TabIndex = 13;
			this.kmno4.KeyDown += new System.Windows.Forms.KeyEventHandler(this.hoatdong_KeyDown);
			// 
			// sdno
			// 
			this.sdno.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.sdno.BackColor = System.Drawing.SystemColors.HighlightText;
			this.sdno.Enabled = false;
			this.sdno.Location = new System.Drawing.Point(474, 464);
			this.sdno.Name = "sdno";
			this.sdno.Size = new System.Drawing.Size(110, 20);
			this.sdno.TabIndex = 18;
			this.sdno.Text = "";
			this.sdno.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
			this.sdno.KeyDown += new System.Windows.Forms.KeyEventHandler(this.hoatdong_KeyDown);
			this.sdno.Validated += new System.EventHandler(this.sdno_Validated);
			// 
			// sdco
			// 
			this.sdco.Anchor = ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			this.sdco.BackColor = System.Drawing.SystemColors.HighlightText;
			this.sdco.Enabled = false;
			this.sdco.Location = new System.Drawing.Point(656, 464);
			this.sdco.Name = "sdco";
			this.sdco.Size = new System.Drawing.Size(128, 20);
			this.sdco.TabIndex = 19;
			this.sdco.Text = "";
			this.sdco.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
			this.sdco.KeyDown += new System.Windows.Forms.KeyEventHandler(this.hoatdong_KeyDown);
			this.sdco.Validated += new System.EventHandler(this.sdco_Validated);
			// 
			// sdcont
			// 
			this.sdcont.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.sdcont.BackColor = System.Drawing.SystemColors.HighlightText;
			this.sdcont.Enabled = false;
			this.sdcont.Location = new System.Drawing.Point(288, 464);
			this.sdcont.Name = "sdcont";
			this.sdcont.Size = new System.Drawing.Size(128, 20);
			this.sdcont.TabIndex = 133;
			this.sdcont.Text = "";
			this.sdcont.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
			this.sdcont.KeyDown += new System.Windows.Forms.KeyEventHandler(this.hoatdong_KeyDown);
			this.sdcont.Validated += new System.EventHandler(this.sdcont_Validated);
			// 
			// sdnont
			// 
			this.sdnont.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.sdnont.BackColor = System.Drawing.SystemColors.HighlightText;
			this.sdnont.Enabled = false;
			this.sdnont.Location = new System.Drawing.Point(83, 464);
			this.sdnont.Name = "sdnont";
			this.sdnont.Size = new System.Drawing.Size(133, 20);
			this.sdnont.TabIndex = 134;
			this.sdnont.Text = "";
			this.sdnont.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
			this.sdnont.KeyDown += new System.Windows.Forms.KeyEventHandler(this.hoatdong_KeyDown);
			this.sdnont.Validated += new System.EventHandler(this.sdnont_Validated);
			// 
			// frmCongno_cu
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(792, 573);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.sdnont,
																		  this.sdcont,
																		  this.sdco,
																		  this.sdno,
																		  this.kmno2,
																		  this.kmno4,
																		  this.label15,
																		  this.kmno,
																		  this.kmno3,
																		  this.label14,
																		  this.label12,
																		  this.nhom,
																		  this.label11,
																		  this.zsdcont,
																		  this.label17,
																		  this.tendt,
																		  this.ttkno,
																		  this.diachi,
																		  this.lk,
																		  this.madt,
																		  this.label27,
																		  this.label46,
																		  this.listdt,
																		  this.zsdno,
																		  this.label4,
																		  this.label5,
																		  this.label8,
																		  this.label10,
																		  this.zsdnont,
																		  this.label2,
																		  this.label3,
																		  this.label1,
																		  this.zsdco,
																		  this.listtkno,
																		  this.ngoaite,
																		  this.label25,
																		  this.tkno,
																		  this.label13,
																		  this.label50,
																		  this.nghiepvu,
																		  this.chuong,
																		  this.label7,
																		  this.label6,
																		  this.label43,
																		  this.tygia,
																		  this.label37,
																		  this.chkIn,
																		  this.find,
																		  this.butKetthuc,
																		  this.butIn,
																		  this.butHuy,
																		  this.butBoqua,
																		  this.butLuu,
																		  this.butSua,
																		  this.butMoi,
																		  this.hoatdong,
																		  this.label9,
																		  this.dataGrid1,
																		  this.stt,
																		  this.stemp});
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.Name = "frmCongno_cu";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "Công nợ";
			this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
			this.Load += new System.EventHandler(this.frmCongno_Load);
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		private void frmCongno_Load(object sender, System.EventArgs e)
		{			
			chkIn.Checked=a.bPreview;
			format_sotien=a.format_sotien(0);
			bKhoaso=a.bKhoaso(s_mmyy);

			nhom.DisplayMember="TEN";
			nhom.ValueMember="ID";
			nhom.DataSource=a.get_data("select * from a_dmnhombc order by stt").Tables[0];

			hoatdong.DisplayMember="TEN";
			hoatdong.ValueMember="ID";
			hoatdong.DataSource=a.get_data("select * from a_hoatdong where sudung=1 order by stt").Tables[0];

			sql="select * from a_dmchuong where sudung=1";
			if (s_chuong!="") sql+=" and id in ("+s_chuong.Substring(0,s_chuong.Length-1)+")";
			sql+=" order by stt";
			chuong.DisplayMember="TEN";
			chuong.ValueMember="ID";
			chuong.DataSource=a.get_data(sql).Tables[0];

			sql="select * from a_nghiepvu where sudung=1";
			if (s_nghiepvu!="") sql+=" and id in ("+s_nghiepvu.Substring(0,s_nghiepvu.Length-1)+")";
			sql+=" order by stt";
			nghiepvu.DisplayMember="TEN";
			nghiepvu.ValueMember="ID";
			nghiepvu.DataSource=a.get_data(sql).Tables[0];
          
			dtdt=a.get_data("select mavt,tendt,diachi,loaidt,id from a_dmdt where sudung=1 order by stt").Tables[0];
			listdt.DisplayMember="MAVT";
			listdt.ValueMember="TENDT";
			listdt.DataSource=dtdt;

			lk.DisplayMember="LK";
			lk.ValueMember="ID";
			lk.DataSource=a.get_data("select id,lk||' '||tlk as lk,tlk from a_dmlk order by stt").Tables[0];

			kmno.DisplayMember="TEN";
			kmno.ValueMember="ID";

			kmno2.DisplayMember="TEN";
			kmno2.ValueMember="ID";

			kmno3.DisplayMember="TEN";
			kmno3.ValueMember="ID";

			kmno4.DisplayMember="TEN";
			kmno4.ValueMember="ID";

			dttk=a.get_data("select stk,ttk,congno,tinhchat,mlns,ctmlns,loaikm,loaikm2,loaikm3,loaikm4,id from a_dmtk where sudung=1 and c=1 and congno=1 order by stk").Tables[0];

            listtkno.DisplayMember="STK";
			listtkno.ValueMember="TTK";
			listtkno.DataSource=dttk;

			sql= "select id,ma,ten,to_char(ngay,'dd/mm/yyyy') as ngay,tygia from a_dmngoaite where sudung=1 order by id";
			dtnt=a.get_data(sql).Tables[0];
			ngoaite.DisplayMember="MA";
			ngoaite.ValueMember="ID";
			ngoaite.DataSource=dtnt;

			load_grid();
			AddGridTableStyle();
			ref_text(0);
		}

		private void load_grid()
		{
			dataGrid1.DataSource=null;
			sql="select a.id,a.idbc,a.loaidt,a.chuong,a.lk,a.nghiepvu,a.madt,a.noidung,a.stka,a.khoanmuc,";
			sql+="a.khoanmuc2,a.khoanmuc3,a.khoanmuc4,a.hoatdong,";
			sql+="a.sdno01,a.sdco01,a.ngoaite,i.ma as mangoaite,a.tygia,a.sdnont01,a.sdcont01,";
			sql+="a.userid,b.ten as tenchuong,c.lk as tenlk,d.stk,e.mavt,e.tendt,";
			sql+="f.ten as tennghiepvu,g.ten as tenkhoanmuc,g2.ten as tenkhoanmuc2,g3.ten as tenkhoanmuc3,g4.ten as tenkhoanmuc4,h.ten as tenhoatdong,e.diachi";
			sql+=" from "+table+s_mmyy.Substring(2)+" a inner join a_dmchuong b on a.chuong=b.id ";
			sql+=" inner join a_dmlk c on a.lk=c.id ";
			sql+=" inner join a_dmtk d on a.stka=d.id ";
			sql+=" left join a_dmdt e on a.madt=e.id ";
			sql+=" left join a_nghiepvu f on a.nghiepvu=f.id ";
			sql+=" left join a_dmkhoanmuc g on a.khoanmuc=g.id ";
			sql+=" left join a_dmkhoanmuc g2 on a.khoanmuc2=g2.id ";
			sql+=" left join a_dmkhoanmuc g3 on a.khoanmuc3=g3.id ";
			sql+=" left join a_dmkhoanmuc g4 on a.khoanmuc4=g4.id ";
			sql+=" left join a_hoatdong h on a.hoatdong=h.id ";
			sql+=" left join a_dmngoaite i on a.ngoaite=i.id";
			sql+=" where a.id<>0 ";
			if (s_chuong!="") sql+=" and a.chuong in ("+s_chuong.Substring(0,s_chuong.Length-1)+")";
			if (s_nghiepvu!="") sql+=" and a.nghiepvu in ("+s_nghiepvu.Substring(0,s_nghiepvu.Length-1)+")";
			if (s_lk!="") sql+=" and a.lk in ("+s_lk.Substring(0,s_lk.Length-1)+")";
			if (bAdmin) sql+=" and a.userid="+i_userid;
			sql+=" order by d.stk";
			dtct=a.get_data(sql).Tables[0];
			dataGrid1.DataSource=dtct;
			tongcong();
		}

		private void ref_text(long id)
		{
			try
			{
				int i=dataGrid1.CurrentCell.RowNumber;
				l_id=(id==0)?long.Parse(dataGrid1[i,0].ToString()):l_id;
				r=a.getrowbyid(dtct,"id="+l_id);
				if (r!=null)
				{
					nhom.SelectedValue=r["idbc"].ToString();
					chuong.SelectedValue=r["chuong"].ToString();
					hoatdong.SelectedValue=r["hoatdong"].ToString();
					nghiepvu.SelectedValue=r["nghiepvu"].ToString();
					lk.SelectedValue=int.Parse(r["lk"].ToString());
					ltkno=long.Parse(r["stka"].ToString());
					decimal st=decimal.Parse(r["sdno01"].ToString());
					sdno.Text=st.ToString(format_sotien);
					st=decimal.Parse(r["sdco01"].ToString());
					sdco.Text=st.ToString(format_sotien);
					st=decimal.Parse(r["sdnont01"].ToString());
					sdnont.Text=st.ToString(format_sotien);
					st=decimal.Parse(r["sdcont01"].ToString());
					sdcont.Text=st.ToString(format_sotien);

					ngoaite.SelectedValue=int.Parse(r["ngoaite"].ToString());
					st=decimal.Parse(r["tygia"].ToString());
					tygia.Text=st.ToString(format_sotien);
					DataRow r1=a.getrowbyid(dttk,"id="+ltkno);
					if (r1!=null)
					{
						tkno.Text=r1["stk"].ToString();
						ttkno.Text=r1["ttk"].ToString();
					}
					load_mtm(tkno.Text,kmno);
					kmno.SelectedIndex=kmno2.SelectedIndex=kmno3.SelectedIndex=kmno4.SelectedIndex=-1;
					kmno.SelectedValue=r["khoanmuc"].ToString();
					kmno2.SelectedValue=r["khoanmuc2"].ToString();
					kmno3.SelectedValue=r["khoanmuc3"].ToString();
					kmno4.SelectedValue=r["khoanmuc4"].ToString();
					madt.Text=r["mavt"].ToString();
					tendt.Text=r["tendt"].ToString();
					diachi.Text=r["diachi"].ToString();
				}
			}
			catch{emp_detail();}
		}

		public Color MyGetColorRowCol(int row, int col)
		{
			//if (this.dataGrid1[row,15].ToString()=="0") return Color.Red;
			//else 
			return Color.Black;
		}

		public delegate Color delegateGetColorRowCol(int row, int col);
		public class DataGridColoredTextBoxColumn : DataGridTextBoxColumn
		{
			private delegateGetColorRowCol _getColorRowCol;
			private int _column;
			public DataGridColoredTextBoxColumn(delegateGetColorRowCol getcolorRowCol, int column)
			{
				_getColorRowCol = getcolorRowCol;
				_column = column;
			}
			protected override void Paint(System.Drawing.Graphics g, System.Drawing.Rectangle bounds, System.Windows.Forms.CurrencyManager source, int rowNum, System.Drawing.Brush backBrush, System.Drawing.Brush foreBrush, bool alignToRight)
			{
				try
				{
					foreBrush = new SolidBrush(_getColorRowCol(rowNum, this._column));
					//backBrush = new SolidBrush(Color.GhostWhite);
				}
				catch{}
				finally
				{
					base.Paint(g, bounds, source, rowNum, backBrush, foreBrush, alignToRight);
				}
			}
		}

		private void AddGridTableStyle()
		{
			DataGridColoredTextBoxColumn TextCol;
			delegateGetColorRowCol de = new delegateGetColorRowCol(MyGetColorRowCol);
			DataGridTableStyle ts =new DataGridTableStyle();
			ts.MappingName = dtct.TableName;
			ts.AlternatingBackColor = Color.Beige;
			ts.BackColor = Color.GhostWhite;
			ts.ForeColor = Color.MidnightBlue;
			ts.GridLineColor = Color.RoyalBlue;
			ts.HeaderBackColor = Color.MidnightBlue;
			ts.HeaderForeColor = Color.Lavender;
			ts.SelectionBackColor = Color.Teal;
			ts.SelectionForeColor = Color.PaleGreen;
			ts.ReadOnly=false;
			ts.RowHeaderWidth=10;
			
			TextCol=new DataGridColoredTextBoxColumn(de, 0);
			TextCol.MappingName = "id";
			TextCol.HeaderText = "";
			TextCol.Width = 0;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid1.TableStyles.Add(ts);

			TextCol=new DataGridColoredTextBoxColumn(de, 1);
			TextCol.MappingName = "tenlk";
			TextCol.HeaderText = "Khoản";
			TextCol.Width = 50;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid1.TableStyles.Add(ts);

			TextCol=new DataGridColoredTextBoxColumn(de,2);
			TextCol.MappingName = "tendt";
			TextCol.HeaderText = "Đối tượng";
			TextCol.Width = dataGrid1.Width-(30+50+100+30+50+80+80+100+100);
			ts.GridColumnStyles.Add(TextCol);
			dataGrid1.TableStyles.Add(ts);

			TextCol=new DataGridColoredTextBoxColumn(de, 3);
			TextCol.MappingName = "stk";
			TextCol.HeaderText = "Số tài khoản";
			TextCol.Width = 100;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid1.TableStyles.Add(ts);

			TextCol=new DataGridColoredTextBoxColumn(de,5);
			TextCol.MappingName = "mangoaite";
			TextCol.HeaderText = "Ngoại tệ";
			TextCol.Width = 30;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid1.TableStyles.Add(ts);

			TextCol=new DataGridColoredTextBoxColumn(de,6);
			TextCol.MappingName = "tygia";
			TextCol.HeaderText = "Tỷ giá";
			TextCol.Width = 50;
			TextCol.Format="###,###,###";
			TextCol.Alignment=HorizontalAlignment.Right;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid1.TableStyles.Add(ts);

			TextCol=new DataGridColoredTextBoxColumn(de,7);
			TextCol.MappingName = "sdnont01";
			TextCol.HeaderText = "Nợ ngoại tệ";
			TextCol.Width = 80;
			TextCol.Format=format_sotien;
			TextCol.Alignment=HorizontalAlignment.Right;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid1.TableStyles.Add(ts);

			TextCol=new DataGridColoredTextBoxColumn(de,8);
			TextCol.MappingName = "sdcont01";
			TextCol.HeaderText = "Có ngoại tệ";
			TextCol.Width = 80;
			TextCol.Format=format_sotien;
			TextCol.Alignment=HorizontalAlignment.Right;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid1.TableStyles.Add(ts);

			TextCol=new DataGridColoredTextBoxColumn(de,9);
			TextCol.MappingName = "sdno01";
			TextCol.HeaderText = "Nợ VND";
			TextCol.Width = 100;
			TextCol.Format=format_sotien;
			TextCol.Alignment=HorizontalAlignment.Right;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid1.TableStyles.Add(ts);

			TextCol=new DataGridColoredTextBoxColumn(de,10);
			TextCol.MappingName = "sdco01";
			TextCol.HeaderText = "Có VND";
			TextCol.Width = 100;
			TextCol.Format=format_sotien;
			TextCol.Alignment=HorizontalAlignment.Right;
			ts.GridColumnStyles.Add(TextCol);
			dataGrid1.TableStyles.Add(ts);
		}


		private void butKetthuc_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		private void ena_object(bool ena)
		{
			find.Enabled=!ena;
			nhom.Enabled=hoatdong.Enabled=chuong.Enabled=nghiepvu.Enabled=ena;
			lk.Enabled=tkno.Enabled=ena;
			dataGrid1.Enabled=!ena;
			madt.Enabled=tendt.Enabled=ena;
			ngoaite.Enabled=sdnont.Enabled=sdcont.Enabled=sdno.Enabled=sdco.Enabled=ena;
			butLuu.Enabled=butBoqua.Enabled=ena;
			butMoi.Enabled=butSua.Enabled=butHuy.Enabled=butIn.Enabled=butKetthuc.Enabled=!ena;
		}

		private void emp_detail()
		{
			l_id=0;
			load_tygia();
			tkno.Text=ttkno.Text=madt.Text=tendt.Text=diachi.Text="";
			sdnont.Text=sdcont.Text=sdno.Text=sdco.Text="";
			kmno.SelectedIndex=-1;
			kmno.Enabled=kmno2.Enabled=kmno3.Enabled=kmno4.Enabled=false;
		}

		private void butMoi_Click(object sender, System.EventArgs e)
		{
			if (bKhoaso)
			{
				MessageBox.Show("Số liệu tháng "+s_mmyy.Substring(0,2)+" năm "+s_mmyy.Substring(2,2)+" đã khóa !\nNếu cần thay đổi thì vào mục khai báo hệ thống",a.Msg);
				return;
			}
			ena_object(true);
			emp_detail();
			bNew=true;
			if (dtct.Rows.Count==0) nhom.Focus();
			else lk.Focus();
		}

		private void butSua_Click(object sender, System.EventArgs e)
		{
			if (dtct.Rows.Count==0) return;
			if (bKhoaso)
			{
				MessageBox.Show("Số liệu tháng "+s_mmyy.Substring(0,2)+" năm "+s_mmyy.Substring(2,2)+" đã khóa !\nNếu cần thay đổi thì vào mục khai báo hệ thống",a.Msg);
				return;
			}
			ena_object(true);
			l_idold=l_id;
			bNew=false;
			load_tygia();
			int km=kmno.SelectedIndex;
			int km2=kmno2.SelectedIndex;
			int km3=kmno3.SelectedIndex;
			int km4=kmno4.SelectedIndex;
			load_mtm(tkno.Text,kmno);
			kmno.SelectedIndex=km;
			kmno2.SelectedIndex=km2;
			kmno3.SelectedIndex=km3;
			kmno4.SelectedIndex=km4;
			lk.Focus();
		}

		private bool Kiemtra()
		{
			ltkno=0;
			if (tkno.Text=="")
			{
				MessageBox.Show("Nhập số tài khoản !",a.Msg);
				tkno.Focus();
				return false;
			}
			r=a.getrowbyid(dttk,"stk='"+tkno.Text+"'");
			if (r==null)
			{
				MessageBox.Show("Tài khoản nợ không hợp lệ !",a.Msg);
				tkno.Focus();
				return false;
			}
			ltkno=long.Parse(r["id"].ToString());
			decimal _sdno=(sdno.Text!="")?decimal.Parse(sdno.Text):0,_sdco=(sdco.Text!="")?decimal.Parse(sdco.Text):0;
			switch (int.Parse(r["tinhchat"].ToString()))
			{
				case 1: //tkno
					if ((_sdno==0 && _sdco!=0) || (_sdno!=0 && _sdco!=0))
					{
						MessageBox.Show("Tài khoản Nợ\nPhải nhập số dư bên Thu !",a.Msg);
						if (sdnont.Enabled) sdnont.Focus();
						else sdno.Focus();
						return false;
					}
					break;
				case 2: //tkco	
					if ((_sdno!=0 && _sdco==0)  || (_sdno!=0 && _sdco!=0))
					{
						MessageBox.Show("Tài khoản Có\nPhải nhập số dư bên Trả !",a.Msg);
						if (sdcont.Enabled) sdcont.Focus();
						else sdco.Focus();
						return false;
					}
					break;
				default:
					if (_sdno!=0 && _sdco!=0)
					{
						MessageBox.Show("Tài khoản lưỡng tính\nPhải nhập số dư bên Thu hoăc bên Trả !",a.Msg);
						if (sdnont.Enabled) sdnont.Focus();
						else sdno.Focus();
						return false;
					}
					break;
			}
			if (madt.Text=="" || tendt.Text=="")
			{
				MessageBox.Show("Nhập đối tượng !",a.Msg);
				madt.Focus();
				return false;
			}
			r=a.getrowbyid(dtdt,"mavt='"+madt.Text+"'");
			if (r==null)
			{
				MessageBox.Show("Đối tượng không hợp lệ !",a.Msg);
				madt.Focus();
				return false;
			}
			lmadt=long.Parse(r["id"].ToString());
			decimal st=((sdno.Text!="")?decimal.Parse(sdno.Text):0)+((sdco.Text!="")?decimal.Parse(sdco.Text):0);
			if (st==0)
			{
				MessageBox.Show("Nhập số tiền !",a.Msg);
				if (sdnont.Enabled) sdnont.Focus();
				else sdno.Focus();
				return false;
			}
			if (nhom.SelectedIndex==-1)
			{
				MessageBox.Show("Chọn nhóm !",a.Msg);
				nhom.Focus();
				return false;
			}
			if (!kiemtra(l_id,long.Parse(nhom.SelectedValue.ToString()),long.Parse(chuong.SelectedValue.ToString()),long.Parse(lk.SelectedValue.ToString()),long.Parse(nghiepvu.SelectedValue.ToString()),lmadt,ltkno,(kmno.SelectedIndex!=-1)?long.Parse(kmno.SelectedValue.ToString()):0,(kmno2.SelectedIndex!=-1)?long.Parse(kmno2.SelectedValue.ToString()):0,(kmno3.SelectedIndex!=-1)?long.Parse(kmno3.SelectedValue.ToString()):0,(kmno4.SelectedIndex!=-1)?long.Parse(kmno4.SelectedValue.ToString()):0,long.Parse(hoatdong.SelectedValue.ToString()),long.Parse(ngoaite.SelectedValue.ToString())))
			{
				string s="Nhóm "+nhom.Text+"\nChương :"+chuong.Text+"\nHoạt động :"+hoatdong.Text+"\nNghiệp vụ :"+nghiepvu.Text;
				s+="\nLoại khoản :"+lk.Text+"\nĐối tượng :"+tendt.Text+"\nSố tài khoản :"+tkno.Text;
				if (kmno.SelectedIndex!=-1) s+="\nKhoản mục 1 :"+kmno.Text;
				if (kmno2.SelectedIndex!=-1) s+="\nKhoản mục 2 :"+kmno2.Text;
				if (kmno3.SelectedIndex!=-1) s+="\nKhoản mục 3 :"+kmno3.Text;
				if (kmno4.SelectedIndex!=-1) s+="\nKhoản mục 4 :"+kmno4.Text;
				s+="\nNgoại tệ :"+ngoaite.Text+"\nĐã nhập !";
				MessageBox.Show(s,a.Msg);
				return false;
			}
			return true;
		}

		private bool kiemtra(long id,long nhom,long chuong,long lk,long nghiepvu,long lmadt,long ltkno,long kmno,long kmno2,long kmno3,long kmno4,long hoatdong,long ngoaite)
		{
			sql="select * from a_congno"+s_mmyy.Substring(2)+" where idbc="+nhom+" and chuong="+chuong+" and lk="+lk+" and nghiepvu="+nghiepvu;
			sql+=" and madt="+lmadt+" and stka="+ltkno+" and khoanmuc="+kmno+" and khoanmuc2="+kmno2+" and khoanmuc3="+kmno3+" and khoanmuc4="+kmno4+" and hoatdong="+hoatdong;
			sql+=" and ngoaite="+ngoaite+" and id<>"+id;
			return a.get_data(sql).Tables[0].Rows.Count==0;
		}
		private void butLuu_Click(object sender, System.EventArgs e)
		{
			if (!Kiemtra()) return;
			l_id=(bNew)?a.getIdcongno():l_id;
			itable = a.tableid("",table+s_mmyy.Substring(2));
			if (bNew) a.upd_eve_tables(itable, i_userid, "ins");
			else
			{
				a.upd_eve_tables(itable, i_userid, "upd");
				a.upd_eve_upd_del(itable, i_userid, "upd",a.fields(table+s_mmyy.Substring(2),"id="+l_id));
				foreach(DataRow r1 in a.get_data("select * from "+table+s_mmyy.Substring(2)+" where id="+l_id).Tables[0].Rows)
				{
					a.updSodudau("a_sd",a.delete,s_mmyy,long.Parse(r1["idbc"].ToString()),long.Parse(r1["chuong"].ToString()),
						long.Parse(r1["lk"].ToString()),long.Parse(r1["stka"].ToString()),
						long.Parse(r1["khoanmuc"].ToString()),long.Parse(r1["khoanmuc2"].ToString()),long.Parse(r1["khoanmuc3"].ToString()),long.Parse(r1["khoanmuc4"].ToString()),
						0,long.Parse(r1["nghiepvu"].ToString()),long.Parse(r1["madt"].ToString()),long.Parse(r1["hoatdong"].ToString()),
						decimal.Parse(r1["sdno01"].ToString()),decimal.Parse(r1["sdco01"].ToString()));
				}
			}
			if (!a.updCongno(s_mmyy,l_id,long.Parse(nhom.SelectedValue.ToString()),0,long.Parse(chuong.SelectedValue.ToString()),long.Parse(lk.SelectedValue.ToString()),long.Parse(nghiepvu.SelectedValue.ToString()),lmadt,"",ltkno,(kmno.SelectedIndex!=-1)?long.Parse(kmno.SelectedValue.ToString()):0,(kmno2.SelectedIndex!=-1)?long.Parse(kmno2.SelectedValue.ToString()):0,(kmno3.SelectedIndex!=-1)?long.Parse(kmno3.SelectedValue.ToString()):0,(kmno4.SelectedIndex!=-1)?long.Parse(kmno4.SelectedValue.ToString()):0,long.Parse(hoatdong.SelectedValue.ToString()),(sdno.Text!="")?decimal.Parse(sdno.Text):0,(sdco.Text!="")?decimal.Parse(sdco.Text):0,long.Parse(ngoaite.SelectedValue.ToString()),(tygia.Text!="")?decimal.Parse(tygia.Text):0,(sdnont.Text!="")?decimal.Parse(sdnont.Text):0,(sdcont.Text!="")?decimal.Parse(sdcont.Text):0,i_userid))
			{
				MessageBox.Show("Không cập nhật được thông tin số dư !",a.Msg);
				return;
			}
			a.updDtsd("","01"+s_mmyy.Substring(2),i_userid);
			if (a.get_data("select * from a_mmyy where mmyy='01"+s_mmyy.Substring(2)+"'").Tables[0].Rows.Count==0) a.updMmyy("01"+s_mmyy.Substring(2),i_userid);
			load_grid();
			ref_text(0);
			tongcong();
			ena_object(false);
			kmno2.Enabled=kmno3.Enabled=kmno4.Enabled=kmno.Enabled=false;
			butMoi.Focus();
		}

		private void butBoqua_Click(object sender, System.EventArgs e)
		{
			l_id=l_idold;
			ref_text(l_id);
			ena_object(false);
			kmno2.Enabled=kmno3.Enabled=kmno4.Enabled=kmno.Enabled=false;
			butMoi.Focus();
		}

		private void dataGrid1_CurrentCellChanged(object sender, System.EventArgs e)
		{
			ref_text(0);
		}

		private void butHuy_Click(object sender, System.EventArgs e)
		{
			try
			{
				if (dtct.Rows.Count==0) return;
				if (bKhoaso)
				{
					MessageBox.Show("Số liệu tháng "+s_mmyy.Substring(0,2)+" năm "+s_mmyy.Substring(2,2)+" đã khóa !\nNếu cần thay đổi thì vào mục khai báo hệ thống",a.Msg);
					return;
				}
				if (MessageBox.Show("Đồng ý hủy số phiếu này ?",a.Msg,MessageBoxButtons.YesNo,MessageBoxIcon.Question)==DialogResult.Yes)
				{
					a.updDtsd("","01"+s_mmyy.Substring(2),i_userid);
					ltkno=lmadt=0;
					r=a.getrowbyid(dttk,"stk='"+tkno.Text+"'");
					if (r!=null) ltkno=long.Parse(r["id"].ToString());
					r=a.getrowbyid(dtdt,"mavt='"+madt.Text+"'");
					if (r!=null) lmadt=long.Parse(r["id"].ToString());
					itable = a.tableid("", table+s_mmyy.Substring(2));
					a.upd_eve_tables(itable, i_userid, "del");
					a.upd_eve_upd_del(itable, i_userid, "del", a.fields(table+s_mmyy.Substring(2), "id=" + l_id));
					a.updSodudau("a_sd",a.delete,s_mmyy,long.Parse(nhom.SelectedValue.ToString()),long.Parse(chuong.SelectedValue.ToString()),
						long.Parse(lk.SelectedValue.ToString()),ltkno,(kmno.SelectedIndex!=-1)?long.Parse(kmno.SelectedValue.ToString()):0,
						(kmno2.SelectedIndex!=-1)?long.Parse(kmno2.SelectedValue.ToString()):0,(kmno3.SelectedIndex!=-1)?long.Parse(kmno3.SelectedValue.ToString()):0,
						(kmno4.SelectedIndex!=-1)?long.Parse(kmno4.SelectedValue.ToString()):0,
						0,long.Parse(nghiepvu.SelectedValue.ToString()),lmadt,long.Parse(hoatdong.SelectedValue.ToString()),
						(sdno.Text!="")?decimal.Parse(sdno.Text):0,(sdco.Text!="")?decimal.Parse(sdco.Text):0);
					a.execute_data("delete from "+table+s_mmyy.Substring(2)+" where id="+l_id);
					a.delrec(dtct,"id="+l_id);
					ref_text(0);
				}
			}
			catch{}
		}

		private void tongcong()
		{
			try
			{
				decimal _sdnont=0,_sdcont=0,_sdno=0,_sdco=0;
				foreach(DataRow r1 in dtct.Rows)
				{
					_sdnont+=decimal.Parse(r1["sdnont01"].ToString());
					_sdcont+=decimal.Parse(r1["sdcont01"].ToString());
					_sdno+=decimal.Parse(r1["sdno01"].ToString());
					_sdco+=decimal.Parse(r1["sdco01"].ToString());
				}
				zsdnont.Text=_sdnont.ToString(format_sotien);
				zsdcont.Text=_sdcont.ToString(format_sotien);
				zsdno.Text=_sdno.ToString(format_sotien);
				zsdco.Text=_sdco.ToString(format_sotien);
			}
			catch{}
		}


		private void butIn_Click(object sender, System.EventArgs e)
		{
	
		}


		private void find_TextChanged(object sender, System.EventArgs e)
		{
			if (this.ActiveControl==find) RefreshChildren(find.Text);
		}

		private void RefreshChildren(string text)
		{
			try
			{
				CurrencyManager cm= (CurrencyManager)BindingContext[dataGrid1.DataSource];
				DataView dv=(DataView)cm.List;			
				sql="stk like '%"+text.Trim()+"%' or tendt like '%"+text.Trim()+"%'";
				dv.RowFilter=sql;
			}
			catch(Exception ex){MessageBox.Show(ex.Message);}
		}

		private void find_Enter(object sender, System.EventArgs e)
		{
			find.Text="";
		}

		private void butFind_Click(object sender, System.EventArgs e)
		{
			/*frmTimthuoc f=new frmTimthuoc(d,s_mmyy,s_loai,i_nhom,i_userid,bAdmin);
			f.ShowDialog();*/
		}

		private void hoatdong_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if (e.KeyCode==Keys.Enter) SendKeys.Send("{Tab}");		
		}


		private void tkno_TextChanged(object sender, System.EventArgs e)
		{
			if (this.ActiveControl==tkno)
			{
				Filter_stk(tkno.Text,listtkno);
				if (kmno.Enabled)
					listtkno.BrowseToDmtk(tkno,ttkno,kmno,tkno.Location.X,tkno.Location.Y+tkno.Height,tkno.Width+ttkno.Width+2,tkno.Height,100);
				else
					listtkno.BrowseToDmtk(tkno,ttkno,ngoaite,tkno.Location.X,tkno.Location.Y+tkno.Height,tkno.Width+ttkno.Width+2,tkno.Height,100);
			}
		}

		private void Filter_stk(string ma,LibList.List list)
		{
			try
			{
				CurrencyManager cm= (CurrencyManager)BindingContext[list.DataSource];
				DataView dv=(DataView)cm.List;
				sql="stk like '"+ma.Trim()+"%' or ttk like '%"+ma.Trim()+"%'";
				dv.RowFilter=sql;
			}
			catch{}
		}

		private void tkno_Validated(object sender, System.EventArgs e)
		{
			DataRow r=a.getrowbyid(dttk,"stk='"+tkno.Text+"'");
			ttkno.Text=(r!=null)?r["ttk"].ToString():"";	
			load_mtm(tkno.Text,kmno);
		}

		private void load_mtm(string stk,ComboBox cb)
		{
			cb.Enabled=false;
			DataTable tmp;
			DataRow r=a.getrowbyid(dttk,"stk='"+stk+"'");
			if (r!=null)
			{
				sql="select * from a_dmkhoanmuc where loaikm="+int.Parse(r["loaikm"].ToString())+" and sudung=1 order by stt";
				tmp=a.get_data(sql).Tables[0];
				cb.DataSource=tmp;
				if (cb.Name=="kmno")
				{
					sql="select * from a_dmkhoanmuc where loaikm="+int.Parse(r["loaikm2"].ToString())+" and sudung=1 order by stt";
					kmno2.DataSource=a.get_data(sql).Tables[0];
					sql="select * from a_dmkhoanmuc where loaikm="+int.Parse(r["loaikm3"].ToString())+" and sudung=1 order by stt";
					kmno3.DataSource=a.get_data(sql).Tables[0];
					sql="select * from a_dmkhoanmuc where loaikm="+int.Parse(r["loaikm4"].ToString())+" and sudung=1 order by stt";
					kmno4.DataSource=a.get_data(sql).Tables[0];
				}
				if (butLuu.Enabled)
				{
					cb.Enabled=tmp.Rows.Count>0;
					if (cb.Name=="kmno") 
					{
						kmno2.Enabled=kmno2.Items.Count>0;
						kmno3.Enabled=kmno2.Items.Count>0;
						kmno4.Enabled=kmno4.Items.Count>0;
					}
					if (cb.Enabled)
					{
						listtkno.Hide();
						cb.Focus();
					}
				}
			}			
		}


		private void listtkno_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if (e.KeyCode==Keys.Enter || e.KeyCode==Keys.Tab)
			{
				try
				{
					tkno_Validated(sender,e);
					listtkno.Hide();
				}
				catch{}		
			}		
		}

		private void tkno_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if(e.KeyCode==Keys.Down || e.KeyCode==Keys.Up) listtkno.Focus();
			else if (e.KeyCode==Keys.Enter || e.KeyCode==Keys.Tab)
			{
				if (listtkno.Visible)	listtkno.Focus();
				else SendKeys.Send("{Tab}");
			}		
		}

		private void ngoaite_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			if (this.ActiveControl==ngoaite) load_tygia();
		}

		private void load_tygia()
		{
			if (ngoaite.SelectedIndex!=-1)
			{
				tygia.Text=dtnt.Rows[ngoaite.SelectedIndex]["tygia"].ToString();
				decimal tg=(tygia.Text!="")?decimal.Parse(tygia.Text):0;
				//stien.Enabled=tg==1;
				sdnont.Enabled=sdcont.Enabled=tg!=1;
				if (tg==1) sdnont.Text=sdcont.Text="";
				else
				{
					decimal st=(sdno.Text!="")?decimal.Parse(sdno.Text):0,nt=(sdnont.Text!="")?decimal.Parse(sdnont.Text):0;
					if (nt!=0 && st==0)
					{
						st=(sdnont.Text!="")?decimal.Parse(sdnont.Text)*tg:0;
						sdno.Text=st.ToString(format_sotien);
					}
					nt=(sdcont.Text!="")?decimal.Parse(sdcont.Text):0;
					st=(sdco.Text!="")?decimal.Parse(sdco.Text):0;
					if (nt!=0 && st==0)
					{
						st=(sdcont.Text!="")?decimal.Parse(sdcont.Text)*tg:0;
						sdco.Text=st.ToString(format_sotien);
					}
				}
			}
		}

		private void sdnont_Validated(object sender, System.EventArgs e)
		{
			try
			{
				decimal st=(sdnont.Text!="")?decimal.Parse(sdnont.Text):0;
				sdnont.Text=st.ToString(format_sotien);
				st*=((tygia.Text!="")?decimal.Parse(tygia.Text):1);
				sdno.Text=st.ToString(format_sotien);
			}
			catch{}
		}

		private void sdcont_Validated(object sender, System.EventArgs e)
		{
			try
			{
				decimal st=(sdcont.Text!="")?decimal.Parse(sdcont.Text):0;
				sdcont.Text=st.ToString(format_sotien);
				st*=((tygia.Text!="")?decimal.Parse(tygia.Text):1);
				sdco.Text=st.ToString(format_sotien);
			}
			catch{}
		}

		private void sdno_Validated(object sender, System.EventArgs e)
		{
			try
			{
				decimal st=(sdno.Text!="")?decimal.Parse(sdno.Text):0;
				sdno.Text=st.ToString(format_sotien);
			}
			catch{}
		}

		private void sdco_Validated(object sender, System.EventArgs e)
		{
			try
			{
				decimal st=(sdco.Text!="")?decimal.Parse(sdco.Text):0;
				sdco.Text=st.ToString(format_sotien);
			}
			catch{}
		}

		private void listdt_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{			
			if (e.KeyCode==Keys.Enter || e.KeyCode==Keys.Tab)
			{
				try
				{
					DataRow r=a.getrowbyid(dtdt,"mavt='"+madt.Text+"'");
					if (r!=null)
					{
						diachi.Text=r["diachi"].ToString();
						tkno.Focus();
					}
				}
				catch{}		
			}
		}

		private void madt_Validated(object sender, System.EventArgs e)
		{
			DataRow r=a.getrowbyid(dtdt,"mavt='"+madt.Text+"'");
			if (r!=null)
			{
				tendt.Text=r["tendt"].ToString();
				diachi.Text=r["diachi"].ToString();
			}
			else madt.Text=tendt.Text=diachi.Text="";
		}

		
		private void Filter_dmdt(string ten)
		{
			try
			{
				CurrencyManager cm= (CurrencyManager)BindingContext[listdt.DataSource];
				DataView dv=(DataView)cm.List;
				dv.RowFilter="tendt like '%"+ten.Trim()+"%'";
			}
			catch{}
		}

		private void tendt_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			
			if(e.KeyCode==Keys.Down || e.KeyCode==Keys.Up) listdt.Focus();
			else if (e.KeyCode==Keys.Enter)
			{
				if (listdt.Visible)	listdt.Focus();
				else SendKeys.Send("{Tab}");
			}
			else if (e.KeyCode==Keys.Escape) listdt.Hide();
		}

		private void tendt_TextChanged(object sender, System.EventArgs e)
		{
			if (this.ActiveControl==tendt && !diachi.Enabled)
			{
				Filter_dmdt(tendt.Text);
				listdt.BrowseToDanhmuc(tendt,madt,tkno,50);
			}
		}

		private void listdt_DoubleClick(object sender, System.EventArgs e)
		{
			try
			{
				DataRow r=a.getrowbyid(dtdt,"mavt='"+madt.Text+"'");
				if (r!=null)
				{
					diachi.Text=r["diachi"].ToString();
					tkno.Focus();
				}
			}
			catch{}		
		}

		private void tendt_DoubleClick(object sender, System.EventArgs e)
		{
			if (this.ActiveControl==tendt && !diachi.Enabled)
			{
				Filter_dmdt(tendt.Text);
				listdt.BrowseToDanhmuc(tendt,madt,tkno,50);
			}
		}	
	}
}
